
var e = !0,
  f = null,
  k = !1,
  m = "",
  n = '" src="',
  o = '" style="',
  p = "&",
  q = "&alt=rss&max-results=20",
  r = "&format=rss_200&max=20",
  t = "&lang=en-us&format=rss_200",
  v = ")",
  w = "/",
  x = "//api.flickr.com/services/feeds/photos_public.gne?id=",
  z = "//api.flickr.com/services/feeds/photos_public.gne?tags=",
  aa = "//images.google.com/images?q=",
  ba = "//picasaweb.google.com/data/feed/api/search?kind=photo&q=",
  ca = "//picasaweb.google.com/data/feed/base/user/",
  da = "//tbn0.google.com/images?q=tbn:",
  ea = "//www.flickr.com/photos/",
  fa = "//www.gstatic.com/ig/modules/image_slideshow/image_slideshow_content/no_img_b.cache.gif",
  ga = "//www.gstatic.com/ig/modules/image_slideshow/image_slideshow_content/no_img_w.cache.gif",
  A = "0",
  B = "10px",
  ha = "4",
  C = "</span>",
  ia = '<div class="list-item-inner"><img id="thm__MODULE_ID__',
  ja = '<span class="ellipsis error-msg">',
  ka = "<span class=ellipsis>",
  la = "?imgmax=512",
  ma = "?kind=album&alt=rss",
  na = "MozOpacity",
  oa = "__MSG_no_title__",
  D = "album_url",
  pa = "alpha(opacity=",
  qa = "backward__MODULE_ID__",
  ra = "block",
  sa = "canvas",
  ta = "clear",
  ua = "color",
  va = "content",
  wa = "control__MODULE_ID__",
  xa = "crop",
  ya = "dim",
  za = "displaytime",
  Aa = "div",
  Ba = "enable",
  Ca = "entry",
  E = "feed",
  F = "feed_url",
  Da = "feeds/photos_public.gne?id=",
  Ea = "filter",
  Fa = "form__MODULE_ID__",
  Ga = "forward__MODULE_ID__",
  Ha = "guid",
  G = "height",
  Ia = "height:",
  Ja = "href",
  Ka = "image-list__MODULE_ID__",
  H = "img",
  La = "imgrefurl",
  I = "inline",
  J = "item",
  Ma = "li",
  Na = "link",
  K = "list-item",
  Oa = "list-item selected",
  Pa = "list-view-frame__MODULE_ID__",
  Qa = "load_error_msg",
  L = "m___MODULE_ID___0",
  Ra = "m___MODULE_ID___1",
  Sa = "m___MODULE_ID___2",
  Ta = "m___MODULE_ID___5",
  Ua = "m___MODULE_ID___b",
  Va = "media:content",
  Wa = "media:thumbnail",
  Xa = "mode",
  M = "mode__MODULE_ID__",
  Ya = "next-arrow__MODULE_ID__",
  Za = "next-button__MODULE_ID__",
  N = "none",
  O = "object",
  $a = "onresize",
  ab = "opacity",
  bb = "pause__MODULE_ID__",
  cb = "play__MODULE_ID__",
  db = "preview-box__MODULE_ID__",
  eb = "preview-container__MODULE_ID__",
  P = "preview-image",
  fb = "preview-title__MODULE_ID__",
  gb = "previous-arrow__MODULE_ID__",
  hb = "previous-button__MODULE_ID__",
  Q = "px",
  ib = "px ",
  jb = 'px"></div>',
  kb = "px;left:",
  lb = 'px;left:0"></div>',
  mb = "px;top:",
  nb = "q",
  ob = "q__MODULE_ID__",
  R = "query",
  pb = "resize",
  qb = "search-field__MODULE_ID__",
  rb = "ss__MODULE_ID__",
  S = "string",
  sb = "tbnh=",
  tb = "tbnid=",
  ub = "tbnw=",
  vb = "thm__MODULE_ID__",
  wb = "thumbnail",
  T = "title",
  U = "type",
  V = "url",
  W = "user",
  xb = "white",
  X = "width",
  yb = "width:",
  Y, Z = {}, $ = window.location.protocol;

/* Google+ Photos changes */
var ac = "plus",
  bc = /\/photos\/(\d+)\/albums\/(\d+)(\?authkey=(.+))?$/i,
  cc = "/albumid/",
  dc = "?kind=photo&alt=rss",
  ec = "&authkey=Gv1sRg";
  
try {
  document.execCommand("BackgroundImageCache", k, e)
} catch (zb) {}

Z.getComputedStyle = function (a, c) {
  var b = 7 == a.nodeType ? a : a.ownerDocument || a.document;
  return b.defaultView && b.defaultView.getComputedStyle && (b = b.defaultView.getComputedStyle(a, m)) ? b[c] : f
};

Z.setOpacity = function (a, c) {
  var b = a.style;
  if (ab in b) b.opacity = c;
  else if (Ea in b) {
    var d = [];
    d.push(pa);
    d.push(100 * c);
    d.push(v);
    b.filter = d.join(m)
  } else na in b && (b.MozOpacity = c)
};

Z.isValidUrl = function (a) {
  var c = /^https?:\/\/|^\//;
  return typeof a == S && c.exec(a) != f
};

Z.Item = function (a, c, b, d, g) {
  this.album_ = a;
  this.boxElement_ = document.createElement(Ma);
  this.boxElement_.className = K;
  var h = this.album_.thumbnail.width || 55,
    i = this.album_.thumbnail.height || 41;
  this.index = b;
  this.selected = k;
  a = [];
  a.push(ia);
  a.push(b);
  g && (a.push(n), a.push(_hesc(this.album_.thumbnail.url)));
  a.push(o);
  var g = h / i,
    l = g > 55 / 41;
  d == l ? (41 < i && (i = 41), h = i * g, d = (55 - h) / 2, 
    a.push(Ia), a.push(i), a.push(kb), a.push(d), a.push(jb)) : 
    (55 < h && (h = 55), i = h / g, d = d ? (41 - i) / 3 : 41 - i >> 1, 
    a.push(yb), a.push(h), a.push(mb), a.push(d), a.push(lb));
  this.boxElement_.innerHTML = a.join(m);
  c.appendChild(this.boxElement_);
  this.thumbnailElement_ = _gel(vb + b);
  this.previewElement_ = f;
  this.storedMaxPreviewWidth_ = 0;
  this.showPreviewInOnLoadFlag_ = k;
  this.isSmallImage_ = e
};

Z.Item.prototype.select = function () {
  this.selected = e;
  this.boxElement_.className = Oa
};

Z.Item.prototype.cancelSelection = function () {
  this.selected = k;
  this.boxElement_.className = K
};

Z.List = function (a, c) {
  this.prefs_ = new _IG_Prefs(__MODULE_ID__);
  this.listElement_ = _gel(Ka);
  this.frameElement_ = _gel(Pa);
  this.previewContainerElement_ = _gel(eb);
  this.titlePreviewElement_ = _gel(fb);
  this.frameWidth_ = 0;
  this.itemWidth_ = 71;
  this.scrollLeft_ = this.listElement_.style.left || 0;
  this.white_ = c == xb ? 1 : 0;
  this.crop_ = a;
  this.selectedIndex_ = 0;
  this.selectedItem_ = f;
  this.maxPreviewWidth_ = 284;
  this.maxPreviewHeight_ = 200;
  this.previewRatio_ = 1.42;
  this.displayErrorElement_ = f;
  this.items = [];
  this.range = [0, 3];
  this.player =
    new Z.Player(this);
  this.addResizer(this.bind(this.onResize));
  this.transitionID_ = this.elapsedTime_ = 0;
  this.transitionCallback_ = this.bind(this.transitionCallback);
  this.transitionTime_ = 360;
  this.transitionStep_ = 40;
  this.targetLeft_ = this.left_ = 0;
  this.step_ = this.speed_ = 40;
  this.scrollCallback_ = this.bind(this.scrollCallback);
  this.loadedThumbnailNum_ = 0;
  this.isMaximized_ = k
};

Y = Z.List.prototype;
Y.addResizer = function (a) {
  window.setTimeout(a, 10);
  window.addEventListener ? window.addEventListener(pb, a, k) : 
    window.attachEvent && window.attachEvent($a, a)
};

Y.onResize = function () {
  this.setRange();
  var a = this.range[1] + 1;
  this.loadThumbnails(a);
  _IG_AdjustIFrameHeight()
};

Y.load = function (a) {
  this.count = a.length;
  this.scrollLeft_ = this.listElement_.style.left = 0;
  this.previewElement_ = f;
  this.previewContainerElement_.innerHTML = m;
  var c = Z.getComputedStyle(this.frameElement_, X);
  this.frameWidth_ = c ? parseInt(c, 10) : this.frameElement_.offsetWidth;
  this.loadedThumbnailNum_ = Math.ceil((this.frameWidth_ + 2) / 
    this.itemWidth_);
  this.items.length = 0;
  this.listElement_.innerHTML = m;
  for (c = 0; c < a.length; c++) {
    var b = new Z.Item(a[c], this.listElement_, c, this.crop_, 
      c < this.loadedThumbnailNum_);
    this.items.push(b);
    var d = function (a, b) {
      return function () {
        a.selectAndPlay_(b);
        return k
      }
    }(this, b);
    b.boxElement_.onclick = d;
    1 == c && this.select(this.items[0])
  }
  a = document.createElement(Aa);
  a.className = ta;
  this.listElement_.appendChild(a);
  this.listElement_.style.width = this.count * this.itemWidth_ + Q
};

Y.loadThumbnails = function (a) {
  a >= this.count && (a = this.count - 1);
  if (!(this.loadedThumbnailNum_ > a)) {
    for (var c = this.loadedThumbnailNum_; c <= a; c++) {
      var b = this.items[c];
      b && (b.thumbnailElement_.src = _hesc(b.album_.thumbnail.url))
    }
    this.loadedThumbnailNum_ += a - this.loadedThumbnailNum_ + 1
  }
};

Y.displayErrorMsg = function () {
  this.player.stop();
  if (this.displayErrorElement_) this.setDisplayErrorElementSize(), 
    this.showDisplayErrorElement();
  else {
    this.displayErrorElement_ = document.createElement(H);
    this.displayErrorElement_.className = P;
    this.displayErrorElement_.style.top = B;
    this.displayErrorElement_.style.left = B;
    var a = this;
    this.displayErrorElement_.onload = function () {
      a.setDisplayErrorElementSize();
      a.showDisplayErrorElement()
    };
    this.displayErrorElement_.src = this.white_ ? ga : fa
  }
  this.titlePreviewElement_.innerHTML =
    ja + this.prefs_.getMsg(Qa) + C;
  this.titlePreviewElement_.removeAttribute(Ja)
};

Y.setDisplayErrorElementSize = function () {
  this.displayErrorElement_.width = this.maxPreviewWidth_;
  this.displayErrorElement_.height = this.maxPreviewHeight_
};

Y.showDisplayErrorElement = function () {
  Z.setOpacity(this.displayErrorElement_, 1);
  this.previewElement_ ? this.previewContainerElement_.replaceChild(
    this.displayErrorElement_, this.previewElement_) : 
    this.previewContainerElement_.appendChild(this.displayErrorElement_);
  this.previewElement_ = this.displayErrorElement_
};

Y.select = function (a) {
  if (a != this.selectedItem_) {
    this.selectedItem_ && this.selectedItem_.cancelSelection();
    this.selectedItem_ = a;
    this.selectedIndex_ = a.index;
    this.selectedItem_.select();
    this.loadPreviewImage(a);
    a.previewElement_.complete && (
      a.storedMaxPreviewWidth_ != this.maxPreviewWidth_ && 
      this.setPreviewAttributes(a), a.showPreviewInOnLoadFlag_ = k, 
      this.preview(a));
    if (a.index < this.range[0]) {
      var c = a.index - this.range[1] + this.range[0];
      this.scroll(this.listElement_, parseInt(this.scrollLeft_, 10), 
      c * this.itemWidth_)
    } else a.index >
      this.range[1] ? (c = a.index + this.range[1] - this.range[0] + 1, 
        this.loadThumbnails(c), this.scroll(this.listElement_, 
        parseInt(this.scrollLeft_, 10), a.index * this.itemWidth_)) : 
        this.setRange();
    a = a.index + 1;
    a >= this.items.length && (a = 0);
    a = this.items[a];
    this.loadPreviewImage(a)
  }
};

Y.loadPreviewImage = function (a) {
  if (!a.previewElement_ || this.isMaximized_ && a.isSmallImage_) 
    a.previewElement_ = document.createElement(H), 
    a.previewElement_.className = P, 
    a.previewElement_.onload = this.bind(this.previewOnLoad, a), 
    this.isMaximized_ ? (a.previewElement_.src = _hesc(a.album_.image.url), 
      a.isSmallImage_ = k) : 
      a.previewElement_.src = _hesc(a.album_.image.url) + la, 
      a.showPreviewInOnLoadFlag_ = e
};

Y.previewOnLoad = function (a) {
  this.setPreviewAttributes(a);
  a.showPreviewInOnLoadFlag_ && (a.showPreviewInOnLoadFlag_ = k, this.preview(a))
};

Y.preview = function (a) {
  a == this.selectedItem_ && ((this.transitionID_ && (
      window.clearInterval(this.transitionID_), this.transitionID_ = 0, 
      Z.setOpacity(this.nextPreviewElement_, 1), 
      this.previewElement_ && (
        this.previewContainerElement_.removeChild(this.previewElement_), 
        this.previewElement_ = this.nextPreviewElement_)), 
        this.previewElement_) ? (
          this.nextPreviewElement_ = a.previewElement_, 
          Z.setOpacity(this.nextPreviewElement_, 0), 
        this.previewContainerElement_.appendChild(this.nextPreviewElement_), 
        this.elapsedTime_ = 0,
        this.transitionID_ = window.setInterval(this.transitionCallback_, 
        this.transitionStep_), 
      this.setPreviewExtra(this.nextPreviewElement_, a)) : (
        this.previewElement_ = a.previewElement_, 
        this.previewContainerElement_.appendChild(a.previewElement_), 
        this.setPreviewExtra(this.previewElement_, a)))
};

Y.setPreviewExtra = function (a, c) {
  var b = this;
  a.onmouseover = function () {
    b.player.clearFadeout()
  };
  a.onclick = c.album_.destination ? function () {
    window.open(c.album_.destination)
  } : f;
  a.setAttribute(T, c.album_.destination);
  this.titlePreviewElement_.href = c.album_.destination;
  var d = [];
  d.push(ka);
  d.push(_hesc(c.album_.title));
  d.push(C);
  this.titlePreviewElement_.innerHTML = d.join(m)
};

Y.transitionCallback = function () {
  this.elapsedTime_ += this.transitionStep_;
  if (this.elapsedTime_ >= this.transitionTime_) {
    if (this.transitionID_ && (window.clearInterval(this.transitionID_), 
      this.transitionID_ = 0), 
      Z.setOpacity(this.nextPreviewElement_, 0.99), this.previewElement_) 
      this.previewContainerElement_.removeChild(this.previewElement_), 
      this.previewElement_ = this.nextPreviewElement_
  } else {
    var a = this.elapsedTime_ / this.transitionTime_;
    Z.setOpacity(this.nextPreviewElement_, a);
    Z.setOpacity(this.previewElement_,
      1 - a)
  }
};

Y.setPreviewAttributes = function (a) {
  var c = a.album_.image.width,
    b = a.album_.image.height,
    d = c / b;
  d > this.previewRatio_ ? 
    (c > this.maxPreviewWidth_ && (c = this.maxPreviewWidth_), 
    b = c / d, a.previewElement_.height = b, 
    a.previewElement_.width = c) : 
      (b > this.maxPreviewHeight_ && (b = this.maxPreviewHeight_), 
      c = b * d, 
      a.previewElement_.width = c, 
      a.previewElement_.height = b);
  a.previewElement_.style.top = (this.maxPreviewHeight_ - b) / 2 + 10 + Q;
  a.previewElement_.style.left = (this.maxPreviewWidth_ - c) / 2 + 10 + Q;
  a.storedMaxPreviewWidth_ = this.maxPreviewWidth_
};

Y.bind = function (a, c) {
  var b = this,
    d = [].slice.call(arguments, 1);
  return function () {
    var c = d.concat([].slice.call(arguments));
    return a.apply(b, c)
  }
};

Y.selectAndPlay_ = function (a) {
  1 === this.player.status && this.player.pause();
  this.select(a);
  2 === this.player.status && this.player.play()
};

Y.scroll = function (a, c, b) {
  a = parseInt(this.listElement_.style.width, 10) - 2;
  b = 0 > b ? 0 : b;
  b + this.frameWidth_ > a && (b = a - this.frameWidth_);
  this.targetLeft_ = b;
  this.left_ = -c;
  this.scrollCallback()
};

Y.scrollCallback = function () {
  this.left_ = this.targetLeft_ > this.left_ ? 
    this.targetLeft_ - this.left_ > this.speed_ ? 
      this.left_ + this.speed_ : this.targetLeft_ : 
      this.left_ - this.targetLeft_ > this.speed_ ? 
        this.left_ - this.speed_ : this.targetLeft_;
  this.listElement_.style.left = -this.left_ + Q;
  this.left_ != this.targetLeft_ ? 
    window.setTimeout(this.scrollCallback_, this.step_) : this.setRange()
};

Y.setRange = function () {
  this.scrollLeft_ = parseInt(this.listElement_.style.left, 10);
  var a = -this.scrollLeft_,
    c = Z.getComputedStyle(this.frameElement_, X);
  this.frameWidth_ = c ? parseInt(c, 10) : this.frameElement_.offsetWidth;
  this.frameWidth_ != this.maxPreviewWidth_ && (
    this.maxPreviewWidth_ = this.frameWidth_, 
    this.maxPreviewHeight_ = this.maxPreviewWidth_ / this.previewRatio_, 
    this.previewContainerElement_.style.height = this.maxPreviewHeight_ + 10 + Q, 
    this.player.controlElement_.style.top = this.maxPreviewHeight_ - 50 + Q, 
    this.previewElement_ && (
      this.previewElement_ == this.displayErrorElement_ ? 
        this.setDisplayErrorElementSize() : this.setPreviewAttributes(this.selectedItem_), 
      this.titlePreviewElement_.innerHTML = this.titlePreviewElement_.innerHTML));
  this.range[0] = Math.ceil(a / this.itemWidth_);
  this.range[1] = Math.floor(this.range[0] + Math.floor((this.frameWidth_ + 2) / this.itemWidth_) - 1);
  this.player.setButton(0, this.white_, 0 >= this.range[0]);
  this.player.setButton(1, this.white_, this.range[1] >= this.count - 2);
  this.player.disableButton(this.player.backwardButtonElement_,
    0 >= this.selectedIndex_);
  this.player.disableButton(this.player.forwardButtonElement_, 
    this.selectedIndex_ >= this.count - 1)
};

Z.Player = function (a) {
  this.previewBox = _gel(db);
  this.controlElement_ = _gel(wa);
  this.previousButtonElement_ = _gel(hb);
  this.nextButtonElement_ = _gel(Za);
  this.previousArrowElement_ = _gel(gb);
  this.nextArrowElement_ = _gel(Ya);
  this.backwardButtonElement_ = _gel(qa);
  this.playButtonElement_ = _gel(cb);
  this.pauseButtonElement_ = _gel(bb);
  this.forwardButtonElement_ = _gel(Ga);
  this.timerHandleCache_ = 0;
  this.interval_ = 3E3;
  this.listObject_ = a || {};
  this.status = 0;
  this.previewBox.onmouseover = this.bind(this.fadein_);
  this.previewBox.onmouseout =
    this.bind(this.fadeout_);
  this.previousButtonElement_.onclick = this.bind(this.moveThumbnailPosition, 4);
  this.nextButtonElement_.onclick = this.bind(this.moveThumbnailPosition, 3);
  this.backwardButtonElement_.onclick = this.bind(this.moveThumbnailPosition, 2);
  this.forwardButtonElement_.onclick = this.bind(this.moveThumbnailPosition, 1);
  this.playButtonElement_.onclick = this.bind(this.play);
  this.pauseButtonElement_.onclick = this.bind(this.stop);
  this.transitionID_ = this.elapsedTime_ = 0;
  this.transitionCallback_ = this.bind(this.transitionCallback);
  this.transitionTime_ = 360;
  this.transitionStep_ = 40;
  this.isFadeIn_ = k
};

Y = Z.Player.prototype;
Y.bind = function (a, c) {
  var b = this,
    d = [].slice.call(arguments, 1);
  return function () {
    var c = d.concat([].slice.call(arguments));
    return a.apply(b, c)
  }
};

Y.moveThumbnailPosition = function (a) {
  var c;
  0 == a ? 
    c = this.listObject_.selectedIndex_ >= this.listObject_.count - 1 ? 
      0 : this.listObject_.selectedIndex_ + 1 : 
  1 == a ? c = this.listObject_.selectedIndex_ + 1 : 
  2 == a ? c = this.listObject_.selectedIndex_ - 1 : 
  3 == a ? c = this.listObject_.range[1] + 1 : 
  4 == a && (c = this.listObject_.range[0] - 1);
  this.listObject_.items[c] && (1 === this.status && this.pause(), 
    this.listObject_.select(this.listObject_.items[c]), 
    2 === this.status && this.play())
};

Y.play = function () {
  var a = this,
    c = function () {
      a.moveThumbnailPosition(0)
    };
  this.timerHandleCache_ = window.setInterval(c, this.interval_);
  this.playButtonElement_.style.display = N;
  this.pauseButtonElement_.style.display = I;
  this.status = 1
};

Y.stop = function () {
  window.clearInterval(this.timerHandleCache_);
  this.playButtonElement_.style.display = I;
  this.pauseButtonElement_.style.display = N;
  this.status = 0
};

Y.pause = function () {
  window.clearInterval(this.timerHandleCache_);
  this.status = 2
};

Y.clearFadeout = function () {
  this.transitionID_ && !this.isFadeIn_ && (
    this.isFadeIn_ = e, 
    this.elapsedTime_ = this.transitionTime_ - this.elapsedTime_)
};

Y.transitionCallback = function () {
  this.elapsedTime_ += this.transitionStep_;
  if (this.elapsedTime_ >= this.transitionTime_)
    (this.transitionID_ && (window.clearInterval(this.transitionID_), 
    this.transitionID_ = 0), this.isFadeIn_) ? 
      Z.setOpacity(this.controlElement_, 1) : 
      (Z.setOpacity(this.controlElement_, 0), 
        this.controlElement_.style.display = N);
  else {
    var a = this.elapsedTime_ / this.transitionTime_;
    this.isFadeIn_ ? 
      Z.setOpacity(this.controlElement_, a) : 
      Z.setOpacity(this.controlElement_, 1 - a)
  }
};

Y.beginTransition = function (a) {
  if (0 != this.transitionID_) 
    this.isFadeIn_ != a && (this.isFadeIn_ = a, 
      this.elapsedTime_ = this.transitionTime_ - this.elapsedTime_);
  else {
    this.elapsedTime_ = 0;
    if (this.isFadeIn_ = a) 
      Z.setOpacity(this.controlElement_, 0.01), 
      this.controlElement_.style.display = ra;
    this.transitionID_ = 
      window.setInterval(this.transitionCallback_, this.transitionStep_)
  }
};

Y.fadein_ = function () {
  this.clearFadeout();
  this.controlElement_.style.display == N && this.beginTransition(e);
  return k
};

Y.fadeout_ = function () {
  this.controlElement_.style.display != N && this.beginTransition(k);
  return k
};

Y.setButton = function (a, c, b) {
  var c = 5 * (2 * c + a),
    d = 9 * b,
    c = -c + ib + -d + Q;
  a ? (this.nextArrowElement_.style.backgroundPosition = c, 
    this.disableButton(this.nextButtonElement_, b)) : 
    (this.previousArrowElement_.style.backgroundPosition = c, 
      this.disableButton(this.previousButtonElement_, b))
};

Y.disableButton = function (a, c) {
  a.className = c ? ya : m
};

Y.setInterval = function (a) {
  this.interval_ = a
};

Z.AlbumEntry = function (a, c, b, d) {
  this.title = a;
  this.destination = c;
  this.thumbnail = b;
  this.image = d
};

Z.ImageEntity = function (a, c, b) {
  this.width = parseInt(a, 10);
  this.height = parseInt(c, 10);
  this.url = b
};

Z.Controller = function () {
  this.prefs_ = new _IG_Prefs(__MODULE_ID__);
  var a = _gel(Ua);
  a && (a.style.padding = A);
  a = this.prefs_.getString(ua);
  _gel(rb).className = a;
  
  var c = this.prefs_.getInt(U), b = _gel(qb);
  0 === c ? b.className = Xa : 
  1 === c || 5 === c ? b.style.display = N : b.className = nb;
  b.form.q.value = this.prefs_.getString(R);
  b = 4 === c ? k : this.prefs_.getString(xa) == Ba;
  this.slideshow_ = new Z.List(b, a);
  a = 1E3 * parseInt(this.prefs_.getString(za), 10);
  this.slideshow_.player.setInterval(a);
  this.picasaAlbums_ = [];
  this.album_ = [];
  
  a = _gel(M);
  this.selectOnChange_ = this.bind(this.selectOnChange, a);
  a.onchange = this.selectOnChange_;

  a = _gel(Fa);
  a.onsubmit = this.bind(this.searchClick);
  if (a = _gel(L)) 
    this.sourceOnChange_ = this.bind(this.sourceOnChange, a), 
    a.onchange = this.sourceOnChange_;
  a = gadgets.views.getCurrentView().getName();
  a == sa && (this.slideshow_.isMaximized_ = e);
  this.sourceOnChange();

  a = this.prefs_.getString(D);
  
  /* Google+ Photos changes */
  if (6 === c) {
    var pc = this.prefs_.getString(ac), 
      qc = bc.exec(pc), 
      rc = qc ? 
        $ + ca + qc[1] + cc + qc[2] + dc + (qc[4] != m ? ec + qc[4] : m) : 
        m;
    rc != m && this.prefs_.set(E, rc)
  }
  
  if (0 === c) {
    var b = _esc(this.prefs_.getString(W)),
      d = $ + ca + b + ma;
    _IG_FetchXmlContent(d, this.bind(this.loadPicasaAlbums), { prefetch: e });
    d != a && this.prefs_.set(D, d)
  } else 
    1 === c ? (b = _esc(this.prefs_.getString(W)), 
      a == b ? (b = this.prefs_.getString(F), this.requestAlbum(b, c)) : 
        (d = $ + ea + b + w, _IG_FetchContent(d, this.bind(function (a) {
      if (!a || typeof a != S) this.slideshow_.displayErrorMsg();
      else {
        var b = a.indexOf(Da);
        if (b == -1) this.slideshow_.displayErrorMsg();
        else {
          b = b + 27;
          a = a.substring(b, a.indexOf(p, b));
          a = $ + x + a + t;
          this.requestAlbum(a, c)
        }
      }
    })), 
    this.prefs_.set(D, b))) : 
    (5 === c || 6 === c ? (b = this.prefs_.getString(E), 
      this.requestAlbum(b, c)) : 
      this.searchClick(), 
      a != m && this.prefs_.set(D, m))
};

Y = Z.Controller.prototype;
Y.bind = function (a, c) {
  var b = this,
    d = [].slice.call(arguments, 1);
  return function () {
    var c = d.concat([].slice.call(arguments));
    return a.apply(b, c)
  }
};

Y.sourceOnChange = function () {
  var a = _gel(L),
    c = _gel(Sa);
  c && (c.parentNode.parentNode.style.display = 5 != a.selectedIndex ? N : m);
  if (c = _gel(Ra)) 
    c.parentNode.parentNode.style.display = 2 > a.selectedIndex ? m : N;
  if (c = _gel(Ta)) 
    c.parentNode.parentNode.style.display = 4 == a.selectedIndex ? N : m
};

Y.selectOnChange = function (a) {
  a = this.picasaAlbums_[a.selectedIndex].guid;
  this.requestAlbum(a, A)
};

Y.searchClick = function () {
  var a = _gel(ob),
    c = this.prefs_.getInt(U),
    a = _esc(a.value),
    b;
  2 === c ? b = $ + ba + a + q : 
  3 === c ? b = $ + z + a + r : 
  4 === c && (b = $ + aa + a);
  this.requestAlbum(b, c);
  c = this.prefs_.getString(R);
  a != c && this.prefs_.set(R, decodeURIComponent(a));
  return k
};

Y.displayAlbum = function () {
  this.slideshow_.player.stop();
  this.slideshow_.load(this.album_);
  this.slideshow_.player.play()
};

Z.PicasaAlbum = function (a, c) {
  this.guid = a;
  this.title = c
};

Z.Controller.prototype.loadPicasaAlbums = function (a) {
  var c = this.picasaAlbums_;
  c.length = 0;
  if (!a || typeof a != O || !a.firstChild) this.slideshow_.displayErrorMsg();
  else {
    for (var a = a.getElementsByTagName(J), b = 0, d; d = a[b]; ++b) {
      var g = d.getElementsByTagName(Ha);
      d = d.getElementsByTagName(T);
      var h, i;
      g && 0 < g.length && (h = g[0].firstChild.nodeValue.replace(Ca, E));
      d && 0 < d.length && (i = d[0].firstChild.nodeValue);
      c[b] = new Z.PicasaAlbum(h, i)
    }
    h = _gel(M);
    i = this.prefs_.getString(F);
    g = 0;
    d = b;
    for (b = 0; b < d; b++) h.options[b] = new Option(c[b].title,
      c[b].guid), i == c[b].guid && (g = b);
    h.options.selectedIndex = g;
    0 < a.length ? 
      setTimeout(this.selectOnChange_, 0) : this.slideshow_.displayErrorMsg();
    _IG_AdjustIFrameHeight()
  }
};

Z.Controller.prototype.requestAlbum = function (a, c) {
  this.album_.length = 0;
  c != ha ? _IG_FetchXmlContent(a, this.bind(this.loadMRSSFeed), {
    prefetch: e
  }) : _IG_FetchContent(a, this.bind(this.loadGoogleImageSearch), {
    prefetch: e
  });
  var b = this.prefs_.getString(F);
  a != b && this.prefs_.set(F, a)
};

Z.Controller.prototype.loadMRSSFeed = function (a) {
  if (!a || typeof a != O || !a.firstChild) this.slideshow_.displayErrorMsg();
  else {
    for (var a = a.getElementsByTagName(J), c, b, d, g, h = 0, i = 0; 
      h < a.length && 20 > i; h++) {
      c = oa;
      var l = a[h].getElementsByTagName(T);
      l && (0 < l.length && l[0].firstChild) && (c = l[0].firstChild.nodeValue);
      var j = a[h].getElementsByTagName(wb);
      0 == j.length && (j = a[h].getElementsByTagName(Wa));
      if (j && 0 < j.length) {
        b = f;
        for (var s = 0; s < j.length; s++) {
          var l = j[s].getAttribute(X),
            y = j[s].getAttribute(G),
            u = j[s].getAttribute(V);
          if ((55 < l && 41 < y || s == j.length - 1) && Z.isValidUrl(u)) {
            b = new Z.ImageEntity(l, y, u);
            break
          }
        }
      }
      j = a[h].getElementsByTagName(va);
      0 == j.length && (j = a[h].getElementsByTagName(Va));
      j && 0 < j.length && (
        l = j[0].getAttribute(X), 
        y = j[0].getAttribute(G), 
        u = j[0].getAttribute(V), 
        d = Z.isValidUrl(u) ? new Z.ImageEntity(l, y, u) : f);
      if ((l = a[h].getElementsByTagName(Na)) && 0 < l.length) 
        g = l[0].firstChild.nodeValue;
      Z.isValidUrl(g) || (g = f);
      b && d && (this.album_[i++] = new Z.AlbumEntry(c, g, b, d))
    }
    0 < this.album_.length ? 
      this.displayAlbum() : this.slideshow_.displayErrorMsg();
    _IG_AdjustIFrameHeight()
  }
};

Z.Controller.prototype.loadGoogleImageSearch = function (a) {
  if (!a || typeof a != S) this.slideshow_.displayErrorMsg();
  else {
    var c = a.match(/008000[^<]+/g);
    if (c) {
      for (var b = 0, d; d = c[b]; ++b) c[b] = _unesc(d.substring(7));
      a = a.match(/\/imgres[^"|^>]+/g);
      for (b = 0; b < a.length && 20 > b; b++) {
        var g = a[b].indexOf(La) + 10;
        d = _unesc(a[b].substring(g, a[b].indexOf(p, g)));
        Z.isValidUrl(d) || (d = f);
        var g = a[b].indexOf(tb) + 6,
          h = a[b].substring(g, a[b].indexOf(p, g)),
          h = $ + da + h,
          g = a[b].indexOf(ub) + 5,
          i = a[b].substring(g, a[b].indexOf(p, g)),
          g = a[b].indexOf(sb) +
            5,
          g = a[b].substring(g, a[b].indexOf(p, g)),
          h = new Z.ImageEntity(i, g, h);
        this.album_[b] = new Z.AlbumEntry(c[b], d, h, h)
      }
      0 < a.length ? this.displayAlbum() : this.slideshow_.displayErrorMsg();
      _IG_AdjustIFrameHeight()
    } else this.slideshow_.displayErrorMsg()
  }
};

new Z.Controller;
